/*
 * Copyright (c) 2016. zhaojin 15398699939@163.com
 */

package com.bankscene.screenfit.activity;

import android.os.Handler;

import com.bankscene.screenfit.events.EventBusEvents;
import com.bankscene.screenfit.vus.LauncherVu;

import org.greenrobot.eventbus.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static com.bankscene.screenfit.events.EventBusEvents.Go2MainActivity.Go2MainActivityFlag.LAUNCHER;

public class LauncherActivity extends BasePresenterActivity<LauncherVu> {

    private Logger log = LoggerFactory.getLogger(LauncherActivity.class);

    @Override
    protected void onBindVu() {
        super.onBindVu();
        log.info("LauncherActivity binded...");
        app.setPad(vu.isPad());
    }

    @Override
    protected void afterResume() {
        super.afterResume();
        new Handler().postDelayed(new Runnable() {
            public void run() {
                bus.post(new EventBusEvents.Go2MainActivity(LAUNCHER));
            }
        }, 1 * 1000);
    }

    @Subscribe
    public void go2MainActivity(EventBusEvents.Go2MainActivity go2MainActivity) {
        log.info("go2MainActivity called...", go2MainActivity);
        MainActivity.newInstance(LauncherActivity.this, null);
        finish();
    }

    @Override
    protected Class<LauncherVu> getVuClass() {
        return LauncherVu.class;
    }
}
